/**
 * Redux 就是事件的订阅和发布模式
 * */


function  createEventBus(){
    let map ={}

    return {
        on(type,handler){
            console.log(handler)
            map[type] = [...(map[type]||[]),handler]
        },
        emit(type,data){
            console.log(map)
            map[type] && map[type].forEach(handler=> handler(data))
        }
    }
}


let events = createEventBus();
events.on('subscriber',(data)=> console.log(data))
events.emit('subscriber',123)
